package com.example.service;

import com.example.consts.RbmConst;
import com.example.mapper.JudgeMapper;
import com.example.model.pojo.Judge;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.Map;

/**
 * @Description //TODO
 * @Date 2022/9/21 18:35
 * @Author lonng
 **/
@Service
public class JudgeServiceImpl implements JudgeService{

    @Autowired
    private JudgeMapper judgeMapper;
    @RabbitListener(queues = RbmConst.Judge_QUEUE)
    @RabbitHandler
    @Override
    public void saveJudge(Map<String,Object> map) {
        judgeMapper.save(new Judge(null,(Integer) map.get("pid"),(String) map.get("uid"),(String) map.get("errorMessage"),
                (Integer) map.get("time"),(Integer) map.get("memory"),
                (Integer) map.get("length"),(String) map.get("code"),(String) map.get("language"),"niumajudger",
                (Integer) map.get("version"),(Date) map.get("gmtCreate"),(Date) map.get("gmtModified")));
    }
}
